#include<iostream>
using namespace std;
int a[5000002],b[5000002];
int main(){
    int n,p;
    cin>>n>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i]-a[i-1];
        //cout<<b[i]<<" ";
    }
    // cout<<endl;
    for(int i=1;i<=p;i++){
        int x,y,z;
        cin>>x>>y>>z;
        b[x]+=z;
        b[y+1]-=z;
    }
    int ans=0x3f3f3f3f;
    for(int i=1;i<=n;i++){
        b[i]=b[i]+b[i-1];
        ans=min(ans,b[i]);
        //cout<<b[i]<<" ";
    }
    cout<<ans;
    return 0;
}